//
//  baseChoseJobKindsCell.swift
//  DingDongZP
//
//  Created by 三秒文化 on 16/4/26.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

import UIKit

class LDBaseChoseJobKindsCell: LDBaseCells {

    var titleLab:UILabel?
    var pilotImg:UIImageView?
    var descLab:UILabel?
    var descText:String?
    
    var model:baseChoseJobKindsCellModel? {
        didSet{
            updateDefaultContent()
        }
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setDefaultContent()
    }
    
    func updateDefaultContent() {
        
        titleLab?.text = model?.level1_name
        descLab?.attributedText = model?.attr
    }
    
    func setDefaultContent() {
        self.selectionStyle = UITableViewCellSelectionStyle.Gray
        
        titleLab = UILabel.setDetailsLab("设置", fontSize: 15, titleColor: LDFontColor.Black,Alignment: nil)
        pilotImg = UIImageView.init(image: UIImage.init(named: "箭头"))
        descLab = UILabel.setDetailsLab("", fontSize: 14, titleColor: LDFontColor.LightGray, Alignment: .Right)
        
        let divideLine = UIView.init()
        divideLine.backgroundColor = LDLineColorLightGray
        addSubview(divideLine)
        
        addSubview(descLab!)
        addSubview(titleLab!)
        addSubview(pilotImg!)
        
        titleLab?.snp_makeConstraints(closure: { (make) in
            make.top.equalTo(LDMargin_V*3)
            make.left.equalTo(Margin_V*2)
            make.height.equalTo(25)
        })
        pilotImg?.snp_makeConstraints(closure: { (make) in
            
            make.centerY.equalTo(titleLab!)
            make.right.equalTo(-LDMargin_V*2)
            make.height.equalTo(15)
            make.width.equalTo(10)
        })
        descLab?.snp_makeConstraints(closure: { (make) in
            make.top.equalTo((titleLab?.snp_bottom)!).offset(LDMargin_V*1)
            make.left.equalTo(LDMargin_V*2)
            make.right.equalTo(-LDMargin_V*2)
        })
        divideLine.snp_makeConstraints { (make) in
            make.bottom.equalTo(self).offset(-0.5)
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.height.equalTo(0.5)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
    }
}
class baseChoseJobKindsCellModel: NSObject {
    
    lazy var height:CGFloat? = {
        
        var attr = self.level2?[0]["level2_name"] as? String
        for item in (self.level2)! {
            let nameStr = item["level2_name"] as! String
            attr?.appendContentsOf(" | \(nameStr)")
        }
        let size = CGSizeMake(LDFrame.ScreenWidth - LDMargin_V*4, 800)
<<<<<<< HEAD
        let hh:CGFloat = String().getHeightFormAttr(8, title: attr!, size: size, font: LDFont.Font14) + LDMargin_V * 3 + 25 + LDMargin_V * 3//titleH
=======
        let hh:CGFloat = String.getHeightFormAttr(8, title: attr!, size: size, font: LDFont.Font14) + LDMargin_V * 3 + 25 + LDMargin_V * 3//titleH
>>>>>>> dingdong2.1.0
        return hh
    }()
    
    lazy var attr:NSMutableAttributedString? = {
        
        var text = self.level2?[0]["level2_name"] as? String
        for item in (self.level2)! {
            let nameStr = item["level2_name"] as! String
            text?.appendContentsOf(" | \(nameStr)")
        }
<<<<<<< HEAD
        let attr = String().getAttrFormString(lineH: 8, text: text!, font: LDFont.Font14)
=======
        let attr = String.getAttrFormString(lineH: 8, text: text!, font: LDFont.Font14)
>>>>>>> dingdong2.1.0
        return attr
    }()
    
    //二级元素便签
    lazy var Level2Title:Array<String> = {
        var arrTitle = [String]()
        for item in (self.level2)! {
            let nameStr:String = item["level2_name"] as! String
            arrTitle.append(nameStr)
        }
        return arrTitle
    }()
    
    //二级元素便签
    lazy var Level2Title_ID:Array<String> = {
        var arrid = [String]()
        for item in (self.level2)! {
            let nameStr:String = item["level2_id"] as! String
            arrid.append(nameStr)
        }
        return arrid
    }()
    var level1_id:String?
    var level1_name:String?
    var level2:Array<NSDictionary>?
    
}
